using MicroMsg.Common.Utils;
using MicroMsg.Storage;
using System;
using System.Collections.Generic;
namespace MicroMsg.UI.UserContrl
{
	public class SnsInfoTranslater
	{
		public void AddSourceListToDestList(MMObservableCollection<SnsUserPageItemData, SnsUserPageItem> DestList, List<SnsInfo> SrcList)
		{
			if (SrcList != null && DestList != null)
			{
				for (int i = 0; i < SrcList.get_Count(); i++)
				{
					SnsUserPageItemData snsUserPageItemData = new SnsUserPageItemData(SrcList.get_Item(i));
					if (snsUserPageItemData.tloObj != null && snsUserPageItemData.tloObj.content.nStyle == 1)
					{
						int num = DestList.get_Count() - 1;
						bool flag = false;
						while (true)
						{
							if (DestList[num].tloObj == null)
							{
								if (DestList[num].strObjectId == "Cover")
								{
									break;
								}
								if (DestList[num].strObjectId == "TakingPhotoIcon")
								{
									break;
								}
							}
							else
							{
								if (DestList[num].tloObj.content.nStyle != 1)
								{
									break;
								}
								if (SrcList.get_Item(i).nLocalID == DestList[num].nLocalID)
								{
									goto Block_6;
								}
								if (SrcList.get_Item(i).strObjectID.CompareTo(DestList[num].strObjectId) < 0)
								{
									break;
								}
							}
							num--;
						}
						IL_F6:
						if (!flag)
						{
							DestList.Insert(num + 1, snsUserPageItemData);
							this.UpdateTimeInfo(ref DestList, num + 1);
							goto IL_10E;
						}
						goto IL_10E;
						Block_6:
						flag = true;
						goto IL_F6;
					}
					IL_10E:;
				}
				return;
			}
		}
		public void DelSourceListFromDestList(MMObservableCollection<SnsUserPageItemData, SnsUserPageItem> DestList, List<SnsInfo> SrcList)
		{
			if (SrcList != null && DestList != null)
			{
				for (int i = 0; i < SrcList.get_Count(); i++)
				{
					SnsUserPageItemData snsUserPageItemData = new SnsUserPageItemData(SrcList.get_Item(i));
					if (snsUserPageItemData.tloObj != null && snsUserPageItemData.tloObj.content.nStyle == 1)
					{
						for (int j = 0; j < DestList.get_Count(); j++)
						{
							if (DestList[j].tloObj != null && DestList[j].tloObj.content.nStyle == 1 && SrcList.get_Item(i).nLocalID == DestList[j].nLocalID)
							{
								DestList.RemoveAt(j);
								this.UpdateTimeInfo(ref DestList, j);
								break;
							}
						}
					}
				}
				return;
			}
		}
		public void ModifyDestList(MMObservableCollection<SnsUserPageItemData, SnsUserPageItem> DestList, List<SnsInfo> SrcList)
		{
			if (SrcList != null && DestList != null)
			{
				for (int i = 0; i < SrcList.get_Count(); i++)
				{
					SnsUserPageItemData snsUserPageItemData = new SnsUserPageItemData(SrcList.get_Item(i));
					if (snsUserPageItemData.tloObj != null && snsUserPageItemData.tloObj.content.nStyle == 1)
					{
						for (int j = 0; j < DestList.get_Count(); j++)
						{
							if (DestList[j].tloObj != null && DestList[j].tloObj.content.nStyle == 1 && SrcList.get_Item(i).nLocalID == DestList[j].nLocalID)
							{
								DestList[j] = snsUserPageItemData;
								this.UpdateTimeInfo(ref DestList, j);
								break;
							}
						}
					}
				}
				return;
			}
		}
		private void UpdateTimeInfo(ref MMObservableCollection<SnsUserPageItemData, SnsUserPageItem> DestList, int index)
		{
			if (DestList == null)
			{
				return;
			}
			DateTime dateTime = Util.SencondsToLocalTime((long)((ulong)DestList[index].nCreateTime));
			if (index - 1 >= 0)
			{
				SnsUserPageItemData snsUserPageItemData = DestList[index];
				if (DestList[index - 1].strObjectId == "Cover")
				{
					snsUserPageItemData.bIsNeedShowData = true;
					DestList[index] = snsUserPageItemData;
				}
				else
				{
					DateTime dateTime2 = Util.SencondsToLocalTime((long)((ulong)DestList[index - 1].nCreateTime));
					if (dateTime.get_Year() == dateTime2.get_Year() && dateTime.get_Month() == dateTime2.get_Month() && dateTime.get_Day() == dateTime2.get_Day())
					{
						snsUserPageItemData.bIsNeedShowData = false;
					}
					else
					{
						snsUserPageItemData.bIsNeedShowData = true;
					}
					DestList[index] = snsUserPageItemData;
				}
			}
			if (index + 1 < DestList.get_Count() && DestList[index + 1].tloObj != null && DestList[index + 1].tloObj.content.nStyle == 1)
			{
				SnsUserPageItemData snsUserPageItemData = DestList[index + 1];
				DateTime dateTime3 = Util.SencondsToLocalTime((long)((ulong)DestList[index + 1].nCreateTime));
				if (dateTime.get_Year() == dateTime3.get_Year() && dateTime.get_Month() == dateTime3.get_Month() && dateTime.get_Day() == dateTime3.get_Day())
				{
					snsUserPageItemData.bIsNeedShowData = false;
				}
				else
				{
					snsUserPageItemData.bIsNeedShowData = true;
				}
				DestList[index + 1] = snsUserPageItemData;
			}
		}
	}
}
